<!DOCTYPE html>
<html lang="en">
    <head>
        {include file="public/header" /}
    </head>
    <body>
        {include file="public/nav" /}
        <div class="container">
            <div class="row">
                <div class="col-lg-12">
                    <div id="content" class="main-content">
                        <div class="page-header">
                            <h2 class="text-center">{$chapter.chat_title}</h2>
                        </div>
                        <div class="art-content">
                            {$chapter.chat_content}
                            <div class="comment-editor">
                                <h4>如果你有什么需要提问或者疑问，可以在下面留言[请文明留言]</h4>
                                <div id="editor">
                                </div>
                                <textarea id="cmmcontent" style="display:none" name="content"></textarea>
                                <div class="comment-submit">                            
                                    <a href="javascript:app.submit();" class="btn btn-primary">确定</a>
                                </div>
                                <hr />
                            </div>
                        </div>
                        <div class="comment">
                            {volist name="comment" id="c"}
                            <div class="comment-list">
                                <div class="cmm-avater"><img src="/home/images/default.png" /></div>
                                <div class="cmm-content">
                                    <div class="cmm-createtime">{$c.bm_createtime|date="Y-m-d",###}：</div>
                                    <div class="cmm-text">{$c.bm_content}</div>
                                </div>
                            </div>
                            <hr />
                            <div class="clearfix"></div>
                            {/volist}
                        </div>
                    </div>
                    <div class="modal fade" tabindex="-1" role="dialog" id="msg-modal">
                        <div class="modal-dialog" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h4 class="modal-title"><i class="fa fa-warning"></i> 提示：</h4>
                                </div>
                                <div class="modal-body">

                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <script type="text/javascript">    
                     SyntaxHighlighter.highlight();  
                    </script>  
                </div>
                </div>
            </div>
        </div>
        {include file="public/footer" /}
        {include file="public/js" /}
        <script src="/home/vendor/we/wangEditor.js"></script>
        <script type="text/javascript">
         (function(){
             var E = window.wangEditor
             var content = '';
             var editor = new E('#editor')
             editor.customConfig.onchange = function (html) {
                 content = html;
             } 
             editor.create();     
             var submit = function(){
                 var id = {$chapter.chat_id};
                 temp = content.replace(/<\/?.+?>/g,"");
                 if(temp == ''){
                     $("#msg-modal").modal('show').on('shown.bs.modal',function(){
                         $(this).find('.modal-body').html("你没有输入内容");
                     });
                 }else{
                     $.ajax({
                         type : "post",
                         url:"addcomment.html",
                         data : {'id':id,'content':content},
                         dataType: 'json',
                         success : function(res){
                             $("#msg-modal").modal('show').on('shown.bs.modal',function(e){
                                 $(this).find('.modal-body').html(res.msg+"（可以再点击课程，即可看到留言）");
                             }).on('hidden.bs.modal',function(){
                                 $(this).find('.modal-body').html('');
                             });                     

                         }
                     })
                 }

             }
             return app.submit = submit;
         }())
        </script>        
    </body>
</html>
